﻿<UserControl x:Class="VmroleAuthor.Views.ViewDefCategoryView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:vm="clr-namespace:VmroleAuthor.ViewModels"
             mc:Ignorable="d" 
             d:DesignWidth="900">
    <UserControl.Resources>
        <Style x:Key="MyButtonStyle" TargetType="Button">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Margin" Value="4" />
            <Setter Property="Height" Value="28" />
            <Setter Property="BorderThickness" Value="0"></Setter>
        </Style>
    </UserControl.Resources>
    <Grid VerticalAlignment="Top" ShowGridLines="False">
        <Grid.RowDefinitions>
            <RowDefinition Height="6" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition MinHeight="30" />
            <RowDefinition Height="Auto" />
            <RowDefinition MinHeight="30" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="6"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="6"/>
        </Grid.ColumnDefinitions>

        <!-- CategoryName -->
        <Label Grid.Row="1" Grid.Column ="0" >CategoryName</Label>
        <ContentControl Grid.Row="1" Grid.Column="2" Content="{Binding Path=CategoryName}" />

        <Label Grid.Row="2" Grid.Column="0"   Content="Add New Parameter"/>
        <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="2">
            <ComboBox x:Name="NewParamCmbBox" VerticalAlignment="Center" Height="28" MinWidth="680" HorizontalAlignment="Left" IsEditable="False"  IsReadOnly="True" ItemsSource="{Binding  AvailableParameters}">
                <ComboBox.ItemTemplate>
                    <DataTemplate DataType="vm:ParameterViewModel">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="6"/>
                                <ColumnDefinition Width="6"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>                            
                            <TextBlock  Grid.Column="0" Text="{Binding Name}"/>
                            <TextBlock  Grid.Column="2" Text="-"/>
                            <TextBlock  Grid.Column="3" Text="{Binding Description}"/>
                        </Grid>
                    </DataTemplate>
                </ComboBox.ItemTemplate>               
             </ComboBox>
            <Button x:Name="ButtonAddNewParam" Style="{StaticResource MyButtonStyle}" HorizontalAlignment="Left" Command="{Binding AddViewDefParameterCommand}"  CommandParameter="{Binding ElementName=NewParamCmbBox, Path=SelectedItem}">
                <Image Source="../Img/addgreen.png"/>
            </Button>
        </StackPanel>
        <ContentPresenter Grid.Row="3" Grid.Column="2" Content="{Binding ElementName=NewParamCmbBox, Path=(Validation.Errors).CurrentItem}" />


        <Label Grid.Row="4" Grid.Column="0" >Parameters</Label>
        <ListBox  Grid.Row="4" Grid.Column="2"  ItemsSource="{Binding ViewDefParameterViewModels}" HorizontalContentAlignment="Stretch">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border CornerRadius="5" Background="LightSteelBlue" HorizontalAlignment="Stretch" Padding="0" Margin="0">
                        <ContentControl  Content="{Binding }" />
                    </Border>                  
                </DataTemplate>
            </ListBox.ItemTemplate>
         </ListBox>
        
        
    </Grid>
              
</UserControl>
